package cn.demo.sys.domain;

import cn.demo.common.annotation.Excel;
import cn.demo.common.annotation.Excel.ColumnType;
import cn.demo.common.core.domain.BaseEntity;
import cn.demo.common.mybatisFlex.MyInsertListener;
import cn.demo.common.mybatisFlex.MyUpdateListener;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.constant.SqlOperator;
import com.mybatisflex.core.query.SqlOperators;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 参数配置表 sys_config
 *
 * @author ruoyi
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(value = "sys_config",onInsert = MyInsertListener.class,onUpdate = MyUpdateListener.class)
public class SysConfig extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 参数主键
     */
    @Id
    @Excel(name = "参数主键", cellType = ColumnType.NUMERIC)
    private String configId;

    /**
     * 参数名称
     */
    @NotBlank(message = "参数名称不能为空")
    @Size(min = 0, max = 100, message = "参数名称不能超过100个字符")
    @Excel(name = "参数名称")
    private String configName;

    /**
     * 参数键名
     */
    @NotBlank(message = "参数键名长度不能为空")
    @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符")
    @Excel(name = "参数键名")
    private String configKey;

    /**
     * 参数键值
     */
    @NotBlank(message = "参数键值不能为空")
    @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符")
    @Excel(name = "参数键值")
    private String configValue;

    /**
     * 系统内置（1是 0否）
     */
    @Excel(name = "系统内置", readConverterExp = "1=是,0=否")
    private Integer configType;

    // 自定义字段的 SQL 操作符
    @JsonIgnore
    public static final SqlOperators operators = SqlOperators.of()
            .set(SysConfig::getConfigName, SqlOperator.LIKE)
            .set(SysConfig::getConfigKey, SqlOperator.LIKE);

}
